package com.ssm.ssmcontroller;


import com.ssm.po.User;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Mars-Hasee on 2017/8/5.
 */
public class UserController2 implements HttpRequestHandler {
    @Override
    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<User> userList = new ArrayList<>();
        request.setAttribute("userList",userList);
        request.getRequestDispatcher("WEB-INF/jsp/index.jsp").forward(request,response);
//        //此种方式可以通过设置response的响应格式 比如json
//        response.setCharacterEncoding("UTF-8");
//        response.setContentType("application/json;charset=UTF-8");
//        response.getWriter().write("json串");
    }


}
